package com.wy.shopping.controller;

import java.util.Arrays;
import java.util.Map;

import com.wy.shopping.vo.ActivityVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.wy.shopping.entity.MiaoshaActivityEntity;
import com.wy.shopping.service.MiaoshaActivityService;
import com.wy.common.utils.PageUtils;
import com.wy.common.utils.R;



/**
 * 
 *
 * @author wangyu
 * @email sunlightcs@gmail.com
 * @date 2022-02-22 18:48:20
 */
@RestController
@RequestMapping("shopping/miaoshaactivity")
public class MiaoshaActivityController {
    @Autowired
    private MiaoshaActivityService miaoshaActivityService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = miaoshaActivityService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 双标连查列表
     */
    @RequestMapping("/miaoshaList")
    public R miaoshaList(@RequestParam Map<String, Object> params){

        return miaoshaActivityService.miaoshaList(params);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		ActivityVo miaoshaActivity = miaoshaActivityService.hui(id);
        return R.ok().put("miaoshaActivity", miaoshaActivity);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody MiaoshaActivityEntity miaoshaActivity){
		miaoshaActivityService.save(miaoshaActivity);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody MiaoshaActivityEntity miaoshaActivity){
		miaoshaActivityService.updateById(miaoshaActivity);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		miaoshaActivityService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
